# -*- encoding: utf-8 -*-
"""

PyCharm 02注释的编写
2024年10月21日17时01分
by wenyang

主要的内容
1. 注释的编写
2. 函数的文档注释编写
3. 注解的编写

"""
from typing import Iterator

def main():
    some_value = "hello world"
    print(some_value)
    new_value = "java"
    print(new_value)
    # 文档的注释
    def print_value(value: str) -> None:
        """
        使用print()函数输出value参数的值
        :param value: 传入的字符传参数
        :return: 返回一个None值
        """
        print(value)
    print_value("hello world javascript")
    def read_lines_from_file(file_path: str) -> Iterator[str]:
        """
        read every line form the given file
        it just handles the rows which is not blank,
        it should ignore the newline character
        by the way, it should not check the existence of the given file
        it's not the business of this function
        let the invoker handle the raises if it does not exist that file
        :param file_path: 文件的位置
        :return: 返回一个迭代器 可以遍历文件的每一行
        """


        with open(file_path, "r") as file:
            # 此处使用的就是:=的海象表达式 可以对语句进行压缩 比如 if line := file.readline(): 就是表示file = file.readline() 并且判断file是否为空
            while line := file.readline():
                line = line.strip()
                if line:
                    yield line
    #调用函数
    read_file_line = read_lines_from_file("./test.txt")
    print(next(read_file_line))
    for oneline in read_lines_from_file("test.txt"):
        print(oneline, end = "\t")





if __name__ == "__main__":
    main()
